home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98c.txt / 000076_icon-group-sender _Fri Nov 13 12:39:19 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  4KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) with SMTP id MAA27101
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Fri, 13 Nov 1998 12:39:19 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA07299; Fri, 13 Nov 1998 12:39:18 -0700
  7. Date: Fri, 13 Nov 1998 12:09:03 -0500 (EST)
  8. From: Mark Laster <mlaster@smart.net>
  9. To: icon-group@optima.CS.Arizona.EDU
  10. Subject: Coding multi-part patterns, as in SNOBOL
  11. Message-Id: <Pine.LNX.3.95.981113120727.7576B-100000@smarty.smart.net>
  12. Mime-Version: 1.0
  13. Content-Type: TEXT/PLAIN; charset=US-ASCII
  14. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  15. Status: RO
  16.  
  17. Subject: Coding multi-part patterns, as in SNOBOL
  18.  
  19. Friday, 11/13/98
  20.  
  21. Hello,
  22.  
  23. After years of programming in SNOBOL, I've been learning ICON, 
  24. but some operations in ICON require me (because I don't know a 
  25. neater way) to write far more lines of code than would be 
  26. necessary in SNOBOL.
  27.  
  28. One of my programs in ICON processes e-mail messages.  It does 
  29. more than the snippet shown here, but for purposes of 
  30. discussion, it removes the "e-mail quotation" marks from lines of 
  31. text.  As you know, those marks in aggregate may be either: 
  32.  
  33.   (1) one or more angle brackets, starting at the left margin, or
  34.  
  35.   (2) one or more spaces, starting at the left margin, FOLLOWED 
  36.       IMMEDIATELY BY one or more angle brackets.
  37.  
  38. To remove these "e-mail quote" marks, I needed about 20 lines, 
  39. as shown below.
  40.  
  41. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  42.  
  43. procedure main ( )
  44.   ...
  45.     # have gotten a line of text, called "rec" here, by now
  46.     repeat {
  47.       if /rec then {
  48.         rec := " "
  49.         break 
  50.         }
  51.  
  52.       else 
  53.       if locnb := many('>', rec) then 
  54.         rec := rec[locnb:0]
  55.  
  56.       if dbg1 := (many(' ', rec)) then {
  57.         if dbg2 := (many('>', rec[dbg1])) then 
  58.           rec := rec[dbg1+dbg2-1:0]
  59.  
  60.         else  # found starting blanks but no ">" immediately after
  61.           break
  62.  
  63.         } # end of "if dbg1 := (many(' ' ..."
  64.  
  65.       else  # rec line does not start with blank or ">"
  66.         break
  67.  
  68.       } # repeat for each workline
  69.       # write the record out
  70.   ...
  71. end
  72.  
  73. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  74.  
  75. To perform the same operation in SNOBOL requires two lines (if 
  76. that many):
  77.  
  78. ...
  79.         qupat = pos(0) (span(" ") | null) span(">") rem . rec
  80. ...
  81. strip   rec qupat :s(strip)
  82. ...
  83. end
  84.  
  85. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  86.  
  87. I've read through the file PATTERNS.ICN, written in 1988, and I
  88. know how to $include it, but I don't know how to use it.  I'd 
  89. be glad to lose some run-time efficiency in order to gain some 
  90. coding-time efficiency.
  91.  
  92. Assuming that there is a way to code the quote-stripping 
  93. operation in ICON more efficiently than I have, optionally 
  94. using the PATTERNS.ICN file or superseding files, could you 
  95. show me how to do it in ICON, so I can see how to combine 
  96. multiple conditions in a match:
  97.  
  98.   (1) starting at the left margin
  99.   (2) optionally encountering one or more blanks
  100.   (3) encountering one or more ">" directly afterward.
  101.  
  102. That would help me learn how to code a variety of complex 
  103. conditions.
  104.  
  105. Thank you very much.
  106.  
  107. Sincerely yours,
  108.  
  109. Mark Laster            (301) 805-4462       mlaster@smart.net
  110. 15775 Easthaven Court
  111. Bowie, MD  20716-2620
  112.  
  113.  
  114.  
  115.